<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Retrieve statistics about a table</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.odbc-specialcolumns.html">« odbc_specialcolumns</a></li>
      <li style="float: right;"><a href="function.odbc-tableprivileges.html">odbc_tableprivileges »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.uodbc.html">ODBC 函数</a></li>
    <li>Retrieve statistics about a table</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.odbc-statistics" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">odbc_statistics</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">odbc_statistics</span> &mdash; <span class="dc-title">Retrieve statistics about a table</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.odbc-statistics-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>odbc_statistics</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">resource</span> <code class="parameter">$odbc</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">?</span><span class="type"><span class="type">string</span><span class="type"></span></span> <code class="parameter">$catalog</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">string</span> <code class="parameter">$schema</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">string</span> <code class="parameter">$table</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">int</span> <code class="parameter">$unique</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">int</span> <code class="parameter">$accuracy</code></span><br>): <span class="type"><span class="type">resource</span>|<span class="type"><span class="type false">false</span></span></span></div>

  <p class="para rdfs-comment">
   Get statistics about a table and its indexes.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.odbc-statistics-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">odbc</code></dt>

     <dd>

      <p class="para">ODBC 连接标识符，详见
<span class="function"><a href="function.odbc-connect.html" class="function">odbc_connect()</a></span>。</p>
     </dd>

    
    
     <dt>
<code class="parameter">catalog</code></dt>

     <dd>

      <p class="para">
       The catalog (&#039;qualifier&#039; in ODBC 2 parlance).
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">schema</code></dt>

     <dd>

      <p class="para">
       The schema (&#039;owner&#039; in ODBC 2 parlance).
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">table</code></dt>

     <dd>

      <p class="para">
       The table name.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">unique</code></dt>

     <dd>

      <p class="para">
       The type of the index.
       One of <strong><code>SQL_INDEX_UNIQUE</code></strong> or <strong><code>SQL_INDEX_ALL</code></strong>.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">accuracy</code></dt>

     <dd>

      <p class="para">
       One of <strong><code>SQL_ENSURE</code></strong> or <strong><code>SQL_QUICK</code></strong>.
       The latter requests that the driver retrieve the <code class="literal">CARDINALITY</code> and
       <code class="literal">PAGES</code> only if they are readily available from the server.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.odbc-statistics-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns an ODBC result identifier 或者在失败时返回 <strong><code>false</code></strong>.
  </p>
  <p class="para">
   The result set has the following columns:
   <ul class="itemizedlist">
    <li class="listitem"><span class="simpara"><code class="literal">TABLE_CAT</code></span></li>
    <li class="listitem"><span class="simpara"><code class="literal">TABLE_SCHEM</code></span></li>
    <li class="listitem"><span class="simpara"><code class="literal">TABLE_NAME</code></span></li>
    <li class="listitem"><span class="simpara"><code class="literal">NON_UNIQUE</code></span></li>
    <li class="listitem"><span class="simpara"><code class="literal">INDEX_QUALIFIER</code></span></li>
    <li class="listitem"><span class="simpara"><code class="literal">INDEX_NAME</code></span></li>
    <li class="listitem"><span class="simpara"><code class="literal">TYPE</code></span></li>
    <li class="listitem"><span class="simpara"><code class="literal">ORDINAL_POSITION</code></span></li>
    <li class="listitem"><span class="simpara"><code class="literal">COLUMN_NAME</code></span></li>
    <li class="listitem"><span class="simpara"><code class="literal">ASC_OR_DESC</code></span></li>
    <li class="listitem"><span class="simpara"><code class="literal">CARDINALITY</code></span></li>
    <li class="listitem"><span class="simpara"><code class="literal">PAGES</code></span></li>
    <li class="listitem"><span class="simpara"><code class="literal">FILTER_CONDITION</code></span></li>
   </ul>
   Drivers can report additional columns.
  </p>
  <p class="simpara">
   The result set is ordered by <code class="literal">NON_UNIQUE</code>, <code class="literal">TYPE</code>, <code class="literal">INDEX_QUALIFIER</code>,
   <code class="literal">INDEX_NAME</code> and <code class="literal">ORDINAL_POSITION</code>.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.odbc-statistics-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="odbc-statistics.example.basic">
   <p><strong>示例 #1 List Statistics of a Table</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$conn&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">odbc_connect</span><span style="color: #007700">(</span><span style="color: #0000BB">$dsn</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$user</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$pass</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$statistics&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">odbc_statistics</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'TutorialDB'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'dbo'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'TEST'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">SQL_INDEX_UNIQUE</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">SQL_QUICK</span><span style="color: #007700">);<br />while&nbsp;((</span><span style="color: #0000BB">$row&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">odbc_fetch_array</span><span style="color: #007700">(</span><span style="color: #0000BB">$statistics</span><span style="color: #007700">)))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$row</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;break;&nbsp;</span><span style="color: #FF8000">//&nbsp;further&nbsp;rows&nbsp;omitted&nbsp;for&nbsp;brevity<br /></span><span style="color: #007700">}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>以上例程的输出类似于：</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
Array
(
    [TABLE_CAT] =&gt; TutorialDB
    [TABLE_SCHEM] =&gt; dbo
    [TABLE_NAME] =&gt; TEST
    [NON_UNIQUE] =&gt;
    [INDEX_QUALIFIER] =&gt;
    [INDEX_NAME] =&gt;
    [TYPE] =&gt; 0
    [ORDINAL_POSITION] =&gt;
    [COLUMN_NAME] =&gt;
    [ASC_OR_DESC] =&gt;
    [CARDINALITY] =&gt; 15
    [PAGES] =&gt; 3
    [FILTER_CONDITION] =&gt;
)
</pre></div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.odbc-statistics-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.odbc-tables.html" class="function" rel="rdfs-seeAlso">odbc_tables()</a> - Get the list of table names stored in a specific data source</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>